import {Injectable} from '@angular/core';
import {HttpUtils} from "../utils/http.utils";
import {USER} from "./user.service";
import {ParamsModel} from "../model/params.model";

@Injectable()
export class APARTMENT {
  appointmentApi: string = '/common/appointment';
  listApi: string = '/apartment';
  myAppointmentList: string = '/appointment';
  topListApi: string = '/apartment';
  getBuildingApi: string = '/building';
  getHouseApi: string = '/house';
  getGoodsApi: string ='/goods';
  getRepairApi: string = '/repairController';
  getMyRentingApi: string = '/contract/renting';
  getMyRepairApi: string = '/repairController';


  constructor(private api: HttpUtils,private USER:USER) {
  }

  appoint(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url = this.appointmentApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.post(pm);
  }



  getMyAppointmentList(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url = this.myAppointmentList;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }

  getList(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url = this.listApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }

  getTopList(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url = this.topListApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }

  getLayoutList(apartmentId: number, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url = '/apartment/' + apartmentId + '/layout';
    pm.succCallback = success;
    this.api.get(pm);
  }

  getDetial(apartmentId: number, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url ='/apartment/' + apartmentId;
    pm.succCallback = success;
    this.api.get(pm);
  }

  getBuildingList(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url =this.getBuildingApi;
    pm.reqestData=params;
    pm.succCallback = success;
    this.api.get(pm);
  }

  getHouseList(params: Object, success: any) {
    let pm = new ParamsModel(this.USER)
    pm.url =this.getHouseApi;
    pm.reqestData=params;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getLayoutDetail(layoutId:number,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = '/layout/'+layoutId+'/detail';
    pm.succCallback = success;
    this.api.get(pm);
  }
  getGoodsList(obj:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.getGoodsApi;
    pm.reqestData = obj;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getGoodsDetail(goodsId:number,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = '/goods/'+goodsId;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getRepair(params:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.getRepairApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.post(pm);
  }
  getMyRenting(params:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.getMyRentingApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getMyRepair(params:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.getMyRepairApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getMyRentingHouse(params:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = '/contract/renting';
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }
}
